<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreatePaymentTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('payment', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('user_id')->comment('用户ID');
            $table->string('order_no', 50)->comment('订单号码');
            $table->string('no', 50)->comment('单号');
            $table->unsignedDecimal('amount')->comment('金额');
            $table->json('request_body')->nullable()->comment('请求信息');
            $table->json('response_body')->nullable()->comment('响应信息');
            $table->json('notify_body')->nullable()->comment('回调信息');
            $table->dateTimeTz('process_at')->nullable()->comment('处理时间');
            $table->unsignedTinyInteger('type')->default(1)->comment('支付类型|{"1":"订单支付","2":"订单退款"}');
            $table->string('code', 25)->comment('支付编码');
            $table->timestampsTz();
            $table->softDeletesTz();
            $table->comment('支付表');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('payment');
    }
}
